<?php

namespace App\Http\Controllers\Api\V1\Site;

use Illuminate\Http\Request;
use Biz\Requests\Site\SiteMailRequest;
use Biz\Services\Site\SiteMailService;
use Biz\Resources\Site\SiteMailResource;
use Lumen\Http\Resources\Json\DataResourceResponse;
use Laravel\Lumen\Routing\Controller as BaseController;

/**
 * MailController.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class MailController extends BaseController
{
    /**
     * @var mixed
     */
    protected $service;

    /**
     * VenueController constructor.
     *
     * @param SiteMailService $service
     */
    public function __construct(SiteMailService $service)
    {
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $site_id = $request->get('site_id');
        $mail    = $this->service->findBySiteId($site_id);

        if (is_null($mail)) {
            $data = [
                'item' => null,
            ];

            return new DataResourceResponse($data);
        }

        return new SiteMailResource($mail);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param SiteMailRequest $request
     *
     * @return \Illuminate\Http\Response
     */
    public function store(SiteMailRequest $request)
    {
        $site = $this->service->save($request->all());

        return new SiteMailResource($site);
    }

//    /**
//     * Display the specified resource.
//     *
//     * @param string $id
//     *
//     * @return \Illuminate\Http\Response
//     */
//    public function show($id)
//    {
//        $site = $this->service->show($id);
//
//        return new SiteMailResource($site);
//    }
//
//    /**
//     * Update the specified resource in storage.
//     *
//     * @param SiteMailRequest $request
//     * @param string          $id
//     *
//     * @return \Illuminate\Http\Response
//     */
//    public function update(SiteMailRequest $request, $id)
//    {
//        $site = $this->service->edit($id, $request->all());
//
//        return new SiteMailResource($site);
//    }
//
//    /**
//     * Remove the specified resource from storage.
//     *
//     * @param string $id
//     *
//     * @return \Illuminate\Http\Response
//     */
//    public function destroy($id)
//    {
//        $result = $this->service->remove($id);
//
//        return new DataResourceResponse($result);
//    }
//
//    /**
//     * Remove the specified resource from storage.
//     *
//     * @param string $id
//     * @param string $locale
//     *
//     * @return \Illuminate\Http\Response
//     */
//    public function deleteTranslations($id, $locale)
//    {
//        $result =  $this->service->deleteTranslations($id, $locale);
//
//        return new DataResourceResponse($result);
//    }
}
